import API from './config.js';
const app = getApp();

function sendFormId(app, method,sessionChoose,callBack) {
  if (!app.globalData.formIds || !app.globalData.formIds.length ) return;
  var formIds = JSON.stringify(app.globalData.formIds);
  var sessionChoose = sessionChoose ? sessionChoose : 2;
  var method = method ? method :"POST";
  var paramSession = [{},
    {
      'content-type': 'application/json'
    },
    {
      'content-type': 'application/x-www-form-urlencoded'
    }
  ];

  

  wx.request({
    url: API.baseUrl+API.collectformid,
    data: { "ids": formIds, "ukey": app.getUkey(), "okey": app.globalData.okey},
    dataType: "json",
    header: paramSession[sessionChoose],
    method: method,
    success: function(res) {
      if (res.status!=0){
        app.globalData.formIds = "";
      }
      callBack && callBack(res.data);
    },
    complete: function() {
     
    }
  })
}

module.exports = sendFormId
